<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f = "http://java.sun.com/jsf/core"
      >
    <h:body>
    	
    	<ui:composition template="/template/commonLayout.xhtml">
    	
    		<ui:define name="content">
		<p:messages id="messages" showDetail="true" autoUpdate="true"
		closable="true" />
	<h4>Hours/Activity</h4>
	<h:form>
		<p:outputLabel for="month" value="Select Activity: " />
		<p:selectOneMenu id="month" value="#{timeIntervalView.selectedActivity}" style="width:150px">
			<f:selectItem itemLabel="Select Activity" itemValue="" noSelectionOption="true" />
			<f:selectItems value="#{timeIntervalView.getActivityNames()}" />
		</p:selectOneMenu>

		<p:outputLabel for="intervalsFrom" value="Select Start-Day: " />
		<p:calendar id="intervalsFrom" value="#{timeIntervalView.from_Date}"
			pattern="dd/MM/yyyy" locale="de">
		</p:calendar>
		
		<p:outputLabel for="intervalsTo" value="Select End-Day: " />
		<p:calendar id="intervalsTo" value="#{timeIntervalView.to_Date}"
			pattern="dd/MM/yyyy" locale="de">
		</p:calendar>
		 <p:commandButton value="Show Timelist" update="outHourList" actionListener="#{timeIntervalView.getIntervalsByActivity()}" icon="ui-icon-check" />

		
		<br />
		<br />

		<p:dataTable id="outHourList" var="dayIntervalData"
			value="#{timeIntervalView.intervalService.dayIntervalDataList}">
			<f:facet name="header">
	            Factor 1:1
	        </f:facet>
			<p:column headerText="Date">
				<h:outputText value="#{dayIntervalData.dateOfIntervals}" >
				<f:convertDateTime pattern="dd/MM/yyyy" />
				</h:outputText>
			</p:column>
			<p:column headerText="Actual Time">
				<h:outputText value="#{dayIntervalData.actualTimeAsString}">
				</h:outputText>
			</p:column>
			<p:column headerText="Allocated Time">
				<h:outputText value="#{dayIntervalData.allocatedTimeAsString}">
				</h:outputText>
			</p:column>
			<p:column headerText="Difference">
				<h:outputText value="#{dayIntervalData.differenceAsString}">
				</h:outputText>
			</p:column>
			<p:columnGroup type="footer">
				<p:row>
					<p:column footerText="Total" style="text-align:right" />
					<p:column
						footerText="#{timeIntervalView.intervalService.sumActualTimeAsString}"
						style="text-align:left" />
					<p:column
						footerText="#{timeIntervalView.intervalService.sumAllocatedTimeAsString}"
						style="text-align:left" />
					<p:column
						footerText="#{timeIntervalView.intervalService.sumTimeDifferenceAsString}"
						style="text-align:left" />
				</p:row>
			</p:columnGroup>
		</p:dataTable>
	</h:form>
	</ui:define>    		
    	</ui:composition>
    	
    </h:body>

</html>